package org.cy.websocket.stomp.protocols;

import org.cy.websocket.stomp.util.StringKit;

/**
 * Created in 2021-05-08 21:59
 *
 * @author cao.yong
 */
public class Versions {

    /**
     * Indicates protocol version 1.0
     */
    public static final String V1_0 = "1.0";
    /**
     * Indicates protocol version 1.1
     */
    public static final String V1_1 = "1.1";
    /**
     * Indicates protocol version 1.2
     */
    public static final String V1_2 = "1.2";

    /**
     * Default versions
     */
    public static final String[] DEFAULTS = new String[]{V1_0, V1_1, V1_2};

    public static String supportedVersions() {
        return StringKit.join(",", DEFAULTS);
    }

    public static String[] protocolVersions() {
        String[] versions = new String[3];
        for (int i = 0; i < DEFAULTS.length; i++) {
            versions[i] = "v" + DEFAULTS[i].replaceAll("\\.", "") + ".stomp";
        }
        return versions;
    }
}
